package com.yjyw.tiexie.util;

import com.yjyw.tiexie.bean.LabelBean;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class UiUtil {
    public static String getPayMoneyByType(int type, double min, double max, String moneyUnit) {
        String s = "";
        switch (type) {
            case 1:
                if (StringUtil.isEmpty(moneyUnit)) {
                    s = "￥" + NumberUtil.moneyNoZero(min + "");
                } else {
                    s = "￥" + NumberUtil.moneyNoZero(min + "") + "/" + moneyUnit;
                }
                break;
            case 3:
                if (StringUtil.isEmpty(moneyUnit)) {
                    s = "￥" + NumberUtil.moneyNoZero(min + "") + "~" + NumberUtil.moneyNoZero(max + "");
                } else {
                    s = "￥" + NumberUtil.moneyNoZero(min + "") + "~" + NumberUtil.moneyNoZero(max + "") + "/" + moneyUnit;
                }
                break;
            case 4:
                s = "费用协商";
                break;
        }
        return s;
    }

    public static String getRelationState(int relationState) {
        String s = "";//1-已关注，2-对方关注我，3-互相关注 0 互不关注
        switch (relationState) {
            case 0:
            case 2:
                s = "关注";
                break;
            case 1:
            case 3:
                s = "已关注";
                break;
        }
        return s;
    }

    public static List<LabelBean> getLabelList(int personNum, int sexScope, String heightRange, String ageRange) {
        List<LabelBean> labelList = new ArrayList<>();
        labelList.clear();
        //人数标签
        if (personNum > 0) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(personNum + "人");
            labelList.add(labelBean);
        }
        //性别标签
        if (sexScope > 0) {
            String sex = "";
            switch (sexScope) {
                case 1:
                    sex = "男";
                    break;
                case 2:
                    sex = "女";
                    break;
                case 3:
                    sex = "不限性别";
                    break;
            }
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(sex);
            labelList.add(labelBean);
        }
        //身高标签
        if (!StringUtil.isEmpty(heightRange)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(heightRange);
            labelList.add(labelBean);
        }
        //年龄标签
        if (!StringUtil.isEmpty(ageRange)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(ageRange);
            labelList.add(labelBean);
        }
        return labelList;
    }


    //    /**
//     * 去除秒:00  2021-08-30 13:36:00  显示2021-08-30 13:36
//     */
    public static String removeTimeHms(String time) {
        String res = "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        try {
            date = simpleDateFormat.parse(time);
            long ts = date.getTime();
            SimpleDateFormat simpleDateFormatNew = new SimpleDateFormat("yyyy-MM-dd");
            Date dateNew = new Date(ts);
            res = simpleDateFormatNew.format(dateNew);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return res;
    }

    /**
     * 去除秒:00  2021-08-30 13:36:00  显示2021-08-30 13:36
     */
    public static String removeTime(String time) {
        String res = "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = simpleDateFormat.parse(time);
            long ts = date.getTime();
            SimpleDateFormat simpleDateFormatNew = new SimpleDateFormat("yyyy-MM-dd");
            Date dateNew = new Date(ts);
            res = simpleDateFormatNew.format(dateNew);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return res;
    }

    //专用
    public static List<LabelBean> getLabelList(String personNum, String sexScope, String heightRange) {
        List<LabelBean> labelList = new ArrayList<>();
        labelList.clear();
        //人数标签
        if (!StringUtil.isEmpty(personNum)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(personNum + "人");
            labelList.add(labelBean);
        } else {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename("若干");
            labelList.add(labelBean);
        }
        //性别标签
        if (!StringUtil.isEmpty(sexScope)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(sexScope);
            labelList.add(labelBean);
        }
        //身高标签
        if (!StringUtil.isEmpty(heightRange)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(heightRange);
            labelList.add(labelBean);
        }
        return labelList;
    }


    public static List<LabelBean> getPersonLabelList(String inAddress, int sex, String school) {
        List<LabelBean> labelList = new ArrayList<>();
        labelList.clear();
        //地点
        if (!StringUtil.isEmpty(inAddress)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(inAddress);
            labelList.add(labelBean);
        }
        //学校
        if (!StringUtil.isEmpty(school)) {
            LabelBean labelBean = new LabelBean();
            labelBean.setLablename(school);
            labelList.add(labelBean);
        }

        return labelList;
    }
}
